package com.cip.master.dao.impl;

import java.util.List;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.cip.admin.dao.impl.CipHibernateDAOSupport;
import com.cip.master.dao.HolidayDAO;
import com.cip.master.model.Holiday;

public class HolidayDAOImpl extends CipHibernateDAOSupport implements  HolidayDAO {
	
	public Holiday getHolidayById(int id) throws Exception{
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();	
		return hibernateTemplate.get(Holiday.class,id);
	}
	
	public Holiday saveOrUpdateHoliday(Holiday holiday) throws Exception{
		
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();	
		hibernateTemplate.saveOrUpdate(holiday);
		return holiday;
	}
	
	public Holiday editHoliday(Holiday holiday) throws Exception{
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();	
		hibernateTemplate.saveOrUpdate(holiday);
		return holiday;
		
	}

	public List<Holiday> getAllHolidayList() throws Exception {
		HibernateTemplate hibernateTemplate = getCipHibernateTemplate();	
		return hibernateTemplate.loadAll(Holiday.class);
	}

}
